using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.IO;

public class EmailGenerator
{
    protected string SourceContent = "";
    private string mail_title = "";

    public string MailTitle
    {
        get { return this.mail_title; }
    }

	public EmailGenerator(string SourceFile)
	{
        // get the file name
        string FileName = SourceFile;
        // read the file
        using (StreamReader FileReader = new StreamReader(FileName, Encoding.UTF8))
        {
            SourceContent = FileReader.ReadToEnd();
            FileReader.Close();
        }
    }

    #region GeneratePending4Aproval
    public string GeneratePending4Aproval(string PMName, string FromDate, string ToDate)
    {
        StringBuilder EmailBuilder = new StringBuilder(this.SourceContent);

        if (this.SourceContent.Length > 0)
        {
            // replace with data
            EmailBuilder.Replace("#PMName#", PMName);
            EmailBuilder.Replace("#FromDate#", FromDate);
            EmailBuilder.Replace("#ToDate#", ToDate);    
            // title
            this.mail_title = this.SourceContent.Substring(
                this.SourceContent.IndexOf("<title>") + "<title>".Length,
                this.SourceContent.IndexOf("</title>") - (this.SourceContent.IndexOf("<title>") + "<title>".Length));
        }
        else
        {
            //this.ErrMsg = "[EmailGenerator.GeneratePending4Aproval] : No source file";
        }

        return EmailBuilder.ToString();
    }
    #endregion
}
